package com.ruoyi.project.device.selectSpaceManage.controller;

import java.util.List;

import com.ruoyi.project.device.space.domain.BasCargoSpace;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.device.selectSpaceManage.domain.BasSelectSpace;
import com.ruoyi.project.device.selectSpaceManage.service.IBasSelectSpaceService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 拣选区货位管理Controller
 * 
 * @author zq
 * @date 2023-08-25
 */
@Controller
@RequestMapping("/BasSelectSpace/spaceManage")
public class BasSelectSpaceController extends BaseController
{
    private String prefix = "device/selectspaceManage";

    @Autowired
    private IBasSelectSpaceService basSelectSpaceService;

    @GetMapping()
    public String spaceManage()
    {
        return prefix + "/spaceManage";
    }

    /**
     * 查询拣选区货位管理列表
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BasSelectSpace basSelectSpace)
    {
        startPage();
        List<BasSelectSpace> list = basSelectSpaceService.selectBasSelectSpaceList(basSelectSpace);
        return getDataTable(list);
    }

    /**
     * 导出拣选区货位管理列表
     */
    @Log(title = "拣选区货位管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BasSelectSpace basSelectSpace)
    {
        List<BasSelectSpace> list = basSelectSpaceService.selectBasSelectSpaceList(basSelectSpace);
        ExcelUtil<BasSelectSpace> util = new ExcelUtil<BasSelectSpace>(BasSelectSpace.class);
        return util.exportExcel(list, "拣选区货位管理数据");
    }

    /**
     * 新增拣选区货位管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存拣选区货位管理
     */
    @Log(title = "拣选区货位管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BasSelectSpace basSelectSpace)
    {
        return toAjax(basSelectSpaceService.insertBasSelectSpace(basSelectSpace));
    }

    /**
     * 修改拣选区货位管理
     */
    @GetMapping("/edit/{cargoSpaceId}")
    public String edit(@PathVariable("cargoSpaceId") String cargoSpaceId, ModelMap mmap)
    {
        BasSelectSpace basSelectSpace = basSelectSpaceService.selectBasSelectSpaceBySpaceId(cargoSpaceId);
        mmap.put("basSelectSpace", basSelectSpace);
        return prefix + "/edit";
    }

    /**
     * 修改保存拣选区货位管理
     */
    @Log(title = "拣选区货位管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BasSelectSpace basSelectSpace)
    {
        return toAjax(basSelectSpaceService.updateBasSelectSpace(basSelectSpace));
    }


    @Log(title = "拣选区货位管理", businessType = BusinessType.UPDATE)
    @PostMapping("/changeLocked")
    @ResponseBody
    public AjaxResult changeLocked(BasSelectSpace basSelectSpace)
    {
        return toAjax(basSelectSpaceService.changeLocked(basSelectSpace));
    }



    /**
     * 删除拣选区货位管理
     */
    @Log(title = "拣选区货位管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(basSelectSpaceService.deleteBasSelectSpaceBySpaceIds(ids));
    }
}
